﻿using System;

using System.Collections.Generic;
using System.Text;

using ScannerApp.ScannerWebserviceWrapper;
using CodeBetter.Json;


namespace ScannerApp
{
    class ScanerWebServiceMock
    {
        static ScanerWebServiceMock _instance;

        public static ScanerWebServiceMock Instance
        {

            get
            {
                if (_instance == null)
                {
                    _instance = new ScanerWebServiceMock();
                }
                return ScanerWebServiceMock._instance;
            }

        }


        public string login(string userName, string pwd)
        {
            BaseResult<Object> result = new BaseResult<Object>();

            if (!userName.StartsWith("a"))
            {
                result.Result = "true";

            }
            else
            {
                result.Result = "false";
            }

            result.ReturnValue = "";
            return Converter.Serialize(result);
        }

        public string checkBarcodeType(string barcode)
        {
            BaseResult<CheckBarcodeTypeResult> result = new BaseResult<CheckBarcodeTypeResult>();
            result.Result = "true";
            CheckBarcodeTypeResult resultValue = new CheckBarcodeTypeResult();
            result.ReturnValue = resultValue;

            resultValue.barCodeType = Convert.ToInt32(ProductBarcodeType.Unknown);
            if (barcode.StartsWith("8610"))
            {
                resultValue.barCodeType = Convert.ToInt32(ProductBarcodeType.QR);
            }
            else if (barcode.StartsWith("12621"))
            {
                resultValue.barCodeType = Convert.ToInt32(ProductBarcodeType.HIBC_First);
            }
            else if (barcode.StartsWith("9900"))
            {
                resultValue.barCodeType = Convert.ToInt32(ProductBarcodeType.HIBC_Second);
            }
            else
            {
                
            }
            return Converter.Serialize(result); ;
        }

        public string inStockOrder(string barcode)
        {
            BaseResult<InStockOrderResult> result = new BaseResult<InStockOrderResult>();
            

            return Converter.Serialize(result);

        }
        public string inStockSingleProduct(string jsonContent)
        {
            InStockSingleProductParameter param = Converter.Deserialize<InStockSingleProductParameter>(jsonContent);

            BaseResult<InStockOrderResult> result = new BaseResult<InStockOrderResult>();
            result.Result = "true";

            
            return Converter.Serialize(result);
        }

        public string inStockCancelSingleProduct(string jsonContent)
        {
            return "";
        }

        public string inStockProducts(string jsonContent)
        {
            InStockProductsParameter param = Converter.Deserialize<InStockProductsParameter>(jsonContent);

            BaseResult<InStockOrderResult> result = new BaseResult<InStockOrderResult>();
            result.Result = "true";

            InStockOrderResult returnValue = new InStockOrderResult();
            

            List<ReceivedGoods> receivedGoods = new List<ReceivedGoods>();
            ReceivedGoods rec = new ReceivedGoods();

            rec.batchNumber = "cPlid1";

            receivedGoods.Add(rec);


            returnValue.recBodyGoodsList = receivedGoods;


            List<ScannedInStockGoods> ScannedInStockGoods = new List<ScannedInStockGoods>();
            ScannedInStockGoods rec1 = new ScannedInStockGoods();
            rec1.prdCode = "instocked_inventoryCode3";
            rec1.prdName = "aa";

            ScannedInStockGoods.Add(rec1);

            rec1 = new ScannedInStockGoods();
            rec1.prdCode = "instocked_inventoryCode3";
            rec1.prdName = "aa";

            ScannedInStockGoods.Add(rec1);


            returnValue.scannedGoods = ScannedInStockGoods;

            result.ReturnValue = returnValue;
            return Converter.Serialize(result);

        }

        public string inStockClearScanedProducts(string jsonContent)
        {
            InStockProductsParameter param = Converter.Deserialize<InStockProductsParameter>(jsonContent);

            BaseResult<InStockOrderResult> result = new BaseResult<InStockOrderResult>();
            result.Result = "true";

            InStockOrderResult returnValue = new InStockOrderResult();


            List<ReceivedGoods> receivedGoods = new List<ReceivedGoods>();
            ReceivedGoods rec = new ReceivedGoods();

            rec.batchNumber = "cPlid1";


            receivedGoods.Add(rec);


            returnValue.recBodyGoodsList = receivedGoods;


            List<ScannedInStockGoods> ScannedInStockGoods = new List<ScannedInStockGoods>();
            ScannedInStockGoods rec1 = new ScannedInStockGoods();
            rec1.prdCode = "ClearScaned_inventoryCode3";
            rec1.prdName = "ClearScaned_batchNumber3";
            rec1.id = "2";

            ScannedInStockGoods.Add(rec1);

            rec1 = new ScannedInStockGoods();
            rec1.prdCode = "inventoryCode2";
            rec1.prdName = "batchNumber2";
            rec1.id = "3";

            ScannedInStockGoods.Add(rec1);


            returnValue.scannedGoods = ScannedInStockGoods;

            result.ReturnValue = returnValue;
            return Converter.Serialize(result);

        }

        public string inStockPutOnShelf(string jsonContent)
        {
            InStockPutOnShelfParameter param = Converter.Deserialize<InStockPutOnShelfParameter>(jsonContent);


            BaseResult<InStockOrderResult> result = new BaseResult<InStockOrderResult>();
            result.Result = "true";

            InStockOrderResult returnValue = new InStockOrderResult();


            List<ReceivedGoods> receivedGoods = new List<ReceivedGoods>();
            ReceivedGoods rec = new ReceivedGoods();

            rec.batchNumber = "cPlid1";

            receivedGoods.Add(rec);


            returnValue.recBodyGoodsList = receivedGoods;


            List<ScannedInStockGoods> ScannedInStockGoods = new List<ScannedInStockGoods>();
            ScannedInStockGoods rec1 = new ScannedInStockGoods();
            rec1.prdCode = "PutOnShelf_inventoryCode3";
            rec1.prdName = "PutOnShelf_batchNumber3";
            rec1.id = "2";

            ScannedInStockGoods.Add(rec1);

            rec1 = new ScannedInStockGoods();
            rec1.prdCode = "PutOnShelf_inventoryCode2";
            rec1.prdName = "batchNumber2";
            rec1.id = "3";

            ScannedInStockGoods.Add(rec1);


            returnValue.scannedGoods = ScannedInStockGoods;

            result.ReturnValue = returnValue;
            return Converter.Serialize(result);
        }

        public string inStockAddAvailableQuantity(string jsonContent)
        {
            InStockAddAvaialableQuantityParameter param = Converter.Deserialize<InStockAddAvaialableQuantityParameter>(jsonContent);

            BaseResult<InStockOrderResult> result = new BaseResult<InStockOrderResult>();
            result.Result = "true";

            InStockOrderResult returnValue = new InStockOrderResult();


            List<ReceivedGoods> receivedGoods = new List<ReceivedGoods>();
            ReceivedGoods rec = new ReceivedGoods();

            rec.batchNumber = "cPlid1";


            receivedGoods.Add(rec);


            returnValue.recBodyGoodsList = receivedGoods;


            List<ScannedInStockGoods> ScannedInStockGoods = new List<ScannedInStockGoods>();
            ScannedInStockGoods rec1 = new ScannedInStockGoods();
            rec1.prdCode = "AddAvaialableQuantity_inventoryCode3";
            rec1.prdName = "AddAvaialableQuantity_batchNumber3";
            rec1.id = "2";

            ScannedInStockGoods.Add(rec1);

            rec1 = new ScannedInStockGoods();
            rec1.prdCode = "inventoryCode2";
            rec1.prdName = "batchNumber2";
            rec1.id = "3";

            ScannedInStockGoods.Add(rec1);


            returnValue.scannedGoods = ScannedInStockGoods;

            result.ReturnValue = returnValue;
            return Converter.Serialize(result);
        }

        public String inStockFinishOrder(String jsonContent)
        {
            InStockProductsParameter param = Converter.Deserialize<InStockProductsParameter>(jsonContent);
            return "";
        }

        public string outStockOrder(string barcode)
        {
            return "";
        }

        public string outStockSingleProduct(string jsonContent)
        {
            return "";
        }

        public string outStockProducts(string jsonContent)
        {
            return "";
        }

        public string outStockClearScanedProducts(string jsonContent)
        {
            return "";
        }

        public string outStockAddDeliveryOrder(string jsonContent)
        {
            return "";
        }


        public string transferStockOrder(string barcode)
        {
            return "";
        }

        public string transferStockSingleProduct(string jsonContent)
        {
            return "";
        }


        public string queryData(string barcode)
        {
            return "";
        }


    }
}
